import Layout from "@/pages/Layout";
import Login from "@/pages/Login";

//配置路由实例
import { createBrowserRouter,createHashRouter } from "react-router-dom";
import AuthRoute from '@/components/AuthRoute/index.jsx'
import { lazy, Suspense } from 'react'
// import Publish from '@/pages/Publish'
// import Article from '@/pages/Article'
// import Home from '@/pages/Home'

// 1.lazy函数组件导入
const Home = lazy(() => import('@/pages/Home'))
const Publish = lazy(() => import('@/pages/Publish'))
const Article = lazy(() => import('@/pages/Article'))


const router = createHashRouter([
  {
    path: "/",
    element: <AuthRoute><Layout /></AuthRoute>,
    children: [
      {
        index: true,
        element: (
          <Suspense fallback={'加载中'}>
            <Home />
          </Suspense>
        ),
      },
      {
        path: 'article',
        element: (
          <Suspense fallback={'加载中'}>
            <Article />
          </Suspense>
        ),
      },
      {
        path: 'publish',
        element: (
          <Suspense fallback={'加载中'}>
            <Publish />
          </Suspense>
        ),
      },
    ],
  },
  {
    path: "/login",
    element: <Login />,
  }

])

export default router;